package com.team2.outpatient_sys.dao;

import com.team2.outpatient_sys.pojo.StorageIn;
import com.team2.outpatient_sys.pojo.StorageInMedicine;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StorageInDao {
    @Insert("insert into storage_in(medicine_id,in_num,in_time,shelves,date_manufacture) values(#{medicineId},#{inNum},#{inTime},#{shelves},#{dateManufacture})")
    public Integer add(StorageIn storageIn);


    @Results({
            @Result(column = "medicine_id" ,property = "medicine",
            one = @One (
                    select = "com.team2.outpatient_sys.dao.MedicineDao.findAllById")
            )
    })
    @Select("select * from storage_in where shelves='否'")
    List<StorageInMedicine> findAllStorageIn();

    @Update("update storage_in set shelves='是' where medicine_id = #{medicineId} and shelves = '否'")
    void updateShelves(Integer medicineId);

    @Results({
            @Result(column = "medicine_id" ,property = "medicine",
                    one = @One (
                            select = "com.team2.outpatient_sys.dao.MedicineDao.findAllById")
            )
    })
    @Select("select * from storage_in where shelves='是'")
    List<StorageInMedicine> findAllStorageInYes();
}
